{{ $path := "" }}

{{ if .File }}
  {{ $path = .File.Path }}
{{ else }}
  {{ if .Page.File }}
    {{ $path = .Page.File.Path }}
  {{ else }}
    {{ if or (eq .RelPermalink "/") (eq .Title "Home") }}
      {{ $path = "_index.md" }}
    {{ end }}
  {{ end }}
{{ end }}

{{ if ne $path "" }}
  {{ $pathFormatted := replace $path "\\" "/" }}

  {{ $gh_repo := $.Site.Params.github.repo }}
  {{ $gh_branch := $.Site.Params.github.branch }}
  {{ $gh_subdir := $.Site.Params.github.subdir }}
  {{ $lang := default "en" $.Site.Language.Lang }}

  {{ $gh_repo_path := printf "%s/content/%s/%s" $gh_subdir $lang $pathFormatted }}
  {{ $editURL := printf "%s/edit/%s/%s" $gh_repo $gh_branch $gh_repo_path }}
  {{ $issuesURL := printf "%s/issues/new?title=%s" $gh_repo (htmlEscape $.Title) }}

  <div class="td-page-meta ml-2 pb-1 pt-2 mb-0">
    <a href="{{ $editURL }}" target="_blank">
      <i class="fa fa-edit fa-fw"></i> {{ T "post_edit_this" }}
    </a>
    <a href="{{ $issuesURL }}" target="_blank">
      <i class="fab fa-github fa-fw"></i> {{ T "post_create_issue" }}
    </a>
  </div>
{{ end }}
